package test;

import static org.junit.Assert.*;

import java.util.Arrays;

import main.Point;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import draw.PointPlotter;

public class PatternRecognitionShould {
	
	private Point point;
	private PointPlotter pointPlotter;
	private String filename;

	@Before
	public void setUp() {
		point = new Point(10, 10);
		pointPlotter = new PointPlotter();
		filename = "collinear/grid4x4.txt";
	}
	
	@Test
	public void drawTest() {
		Point p = new Point(10,10);
		p.draw();
		Point p1 = new Point(20,20);
		p.drawTo(p1);
	}
	
	@Test
	public void plotPointsFromFile() {
//		pointPlotter.plot(filename);
	}
	
	@Test
	public void compareTwoPoints() {
		assertEquals(1, point.compareTo(new Point(10, 2)));
		assertEquals(-1, point.compareTo(new Point(10, 15)));
		assertEquals(1, point.compareTo(new Point(-14, 10)));
		assertEquals(-1, point.compareTo(new Point(987, 10)));
		assertEquals(0, point.compareTo(new Point(10, 10)));
	}
	
	@Test
	public void getSlopeOfTwoPoints() {
		assertEquals(1, point.slopeTo(new Point(20,20)), 0.01);
		assertEquals(3.23, point.slopeTo(new Point(23,52)), 0.01);
		//horizontal line
		assertEquals(0.0, point.slopeTo(new Point(20,10)), 0.01);
		//horizontal line
		assertEquals(0.0, point.slopeTo(new Point(-20,10)), 0.01);
		//vertical line
		assertEquals(Double.POSITIVE_INFINITY, point.slopeTo(new Point(10, 68)), 0.01);
		//degenerate point
		assertEquals(Double.NEGATIVE_INFINITY, point.slopeTo(new Point(10, 10)), 0.01);
	}
	
//	@Test
//	public void sortUsingSLOPE_ORDERComparator() {
//		Arrays.sort(point_arr, c);
//	}
	@After
	public void tearDown() throws Exception {
	}
	
}
